package com.gwall.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;

public class LdapConfig {
    @Configuration
    public class LadpConfig {

        //${xxx}代表是变量以你自己实际的为准
        String ldapUrl = "ldap://10.255.35.220:389";
        String base = "dc=ifyou,dc=com";
        String userName = "cn=auth,ou=People,dc=ifyou,dc=com";
        String passWord ="AudT02132TKW222";

        @Bean
        public LdapContextSource ldapContextSource(){
            LdapContextSource source = new LdapContextSource();
            source.setBase(base);
            source.setUrl(ldapUrl);
            source.setPassword(passWord);
            source.setUserDn(userName);
            return source;
        }

        @Bean
        public LdapTemplate ldapTemplate(){
            return new LdapTemplate(ldapContextSource());
        }

    }

}
